import type { TreeNode } from './types'
import request from '@/axios'

const pathPrefix = '/api/resource'

export const tree = (): Promise<TreeNode[]> => {
    return request.get<TreeNode[]>({
        url: `${pathPrefix}/tree`
    })
}

/**
 * 用户可授权的资源树
 * @returns 
 */
export const assignable = (): Promise<TreeNode[]> => {
    return request.get<TreeNode[]>({
        url: `${pathPrefix}/assignable`
    })
}

export const remove = (id: string): Promise<ApiResult> => {
    return request.delete({
        url: `${pathPrefix}/${id}`
    })
}